<template>
	<view class="changeInfo">
		<view v-if="isLoading == true"><image class="loading" src="https://huajia-online-1316192331.cos.ap-guangzhou.myqcloud.com/static/loading-1.gif"></image></view>
		<view v-if="isLoading == false">
			<button class="edit" size="mini" @click="edit">进入编辑</button>
			<view class="img-box">
				<image class="img" :src="src"></image>
				<view class="text">头像</view>
			</view>
			<view class="seperator"></view>
			<view class="info-box">
				<view class="text-box">
					<view class="left">昵称</view>
					<view class="iconfont iconchangyongicon- icon-box"></view>
					<view class="right">{{ user.userName }}</view>
				</view>
				<view class="text-box">
					<view class="left">姓名</view>
					<view class="iconfont iconchangyongicon- icon-box"></view>
					<view class="right">{{ user.name }}</view>
				</view>
				<view class="text-box">
					<view class="left">手机号</view>
					<view class="iconfont iconchangyongicon- icon-box"></view>
					<view class="right">{{ user.phone }}</view>
				</view>
				<view class="text-box">
					<view class="left">邮箱</view>
					<view class="iconfont iconchangyongicon- icon-box"></view>
					<view class="right">{{ user.email }}</view>
				</view>
			
				<view class="text-box">
					<view class="left">简介</view>
					<view class="iconfont iconchangyongicon- icon-box"></view>
					<view class="right">{{ user.introduction }}</view>
				</view>
				<view class="text-box">
					<view class="left">性别</view>
					<view class="iconfont iconchangyongicon- icon-box"></view>
					<view class="right">{{ user.sex }}</view>
				</view>
				<view class="text-box">
					<view class="left">生日</view>
					<view class="iconfont iconchangyongicon- icon-box"></view>
					<view class="right">{{ user.birthday }}</view>
				</view>
				<view class="text-box">
					<view class="left">地区</view>
					<view class="iconfont iconchangyongicon- icon-box"></view>
					<view class="right">{{ user.address }}</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
export default {
	data() {
		return {
			src: '',
			user: {
				userName: '',
				phone: '',
				email: '',
				introduction: '',
				sex: '',
				birthday: '',
				address: '',
				name:'',
				
			},
			isLoading:true
		};
	},
	methods: {
		edit() {
			uni.navigateTo({
				url: '/pages/edit_personal_data/edit_personal_data'
			});
		}
	},
	onLoad() {
		let that = this;
		that.ajax(that.url.searchUserById, 'POST', {}, function(resp) {
			that.user.userName = resp.data.result[0].nickname;
			that.user.name = resp.data.result[0].name;
			that.user.phone = resp.data.result[0].tel;
			that.user.email = resp.data.result[0].email;
			that.user.sex = resp.data.result[0].sex;
			that.src = resp.data.result[0].photo;
			that.user.introduction = resp.data.result[0].introduction;
			that.user.birthday = resp.data.result[0].birthday;
			that.user.address = resp.data.result[0].address;
		});
		setTimeout(function(resp) {
			that.isLoading = false
		}, 400);
	}
};
</script>

<style lang="less">
@import url('personal_data.less');
</style>
